;; LSP 客户端插件 eglot 配置

(require 'init-package)

(when (maybe-require-package 'eglot)
  (autoload 'eglot-ensure "eglot" "Auto Load eglot.")
  ;; (dolist (hook '(c-mode js-mode typescript-mode python-mode))
  ;;   (add-hook hook 'eglot-ensure))
  )
(with-eval-after-load 'eglot
  (define-key eglot-mode-map (kbd "C-c f") 'eglot-format-buffer)
  (define-key eglot-mode-map (kbd "C-c r") 'eglot-rename)
  (define-key eglot-mode-map (kbd "C-c o") 'eglot-code-action-organize-imports)
  (define-key eglot-mode-map (kbd "C-c h") 'eldoc)

  ;; (setq read-process-output-max (* 1024 1024)
  ;;       eldoc-echo-area-use-multiline-p nil
  ;;       eglot-events-buffer-size 0)
  ;; (push :documentHighlightProvider eglot-ignored-server-capabilities)

  )

;; 注册 Language Server
;; (add-to-list 'eglot-server-programs
;;              '(foo-mode . ("foo-language-server" "--args")))
;; 多模式注册 Language Server
;; (add-to-list 'eglot-server-programs
;;              '((c++-mode c-mode) . (eglot-ccls "~/.emacs.d/tools/ccls")))
;; (defclass eglot-ccls (eglot-lsp-server) ()
;;   :documentation "A custom class for ccls C/C++ langserver.")

(provide 'init-eglot)
